<%--
  Created by IntelliJ IDEA.
  User: 迷路的麋鹿
  Date: 2018/3/29
  Time: 15:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="org.apache.commons.fileupload.disk.*" %>
<%@ page import="com.pml.util.IpTimeStamp" %>
<%@ page import="org.apache.commons.fileupload.servlet.ServletFileUpload" %>
<%@ page import="java.util.List" %>
<%@ page import="org.apache.commons.fileupload.FileItem" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.io.File" %>
<%@ page import="java.io.InputStream" %>
<%@ page import="java.io.OutputStream" %>
<%@ page import="java.io.FileOutputStream" %>
<%@ page import="com.pml.util.FileUploadUtil" %>
<%@ page import="java.util.Map" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <%

/*        OutputStream output=new FileOutputStream(new File("e://y.text"));
        DiskFileItemFactory diskFileItemFactory=new DiskFileItemFactory();
        diskFileItemFactory.setRepository(new File(request.getServletContext().getRealPath("/")+"uploadtemp"));
        ServletFileUpload servletFileUpload=new ServletFileUpload(diskFileItemFactory);
        servletFileUpload.setFileSizeMax(100000000);*/
        /*List<FileItem> fileItemList=servletFileUpload.parseRequest(request);
        Iterator<FileItem> fileItemIterator=fileItemList.iterator();
        IpTimeStamp ipTimeStamp=new IpTimeStamp("199.32.44.55");
        while (fileItemIterator.hasNext()){
            InputStream inputStream=null;

            FileItem item=fileItemIterator.next();
            if(!item.isFormField()) {
                inputStream = item.getInputStream();
                int length=item.getName().split("\\.").length;
                String newFileName=ipTimeStamp.getRandomName()+"."+item.getName().split("\\.")[length-1];
                OutputStream outputStream = new FileOutputStream(new File(request.getServletContext().getRealPath("/")+"upload"+File.separator+newFileName));
                byte[] bytes = new byte[1024];
                int temp = 0;
                while ((temp = inputStream.read(bytes)) != -1) {
                    outputStream.write(bytes);
                }
            }
            else{
                out.print(item.getString());
            }


        }*/


        FileUploadUtil fileUploadUtil=new FileUploadUtil(request,10000000000L,request.getServletContext().getRealPath("/")+"uploadtemp");
        String name=fileUploadUtil.getParameter("name");
        out.print(name);
        out.print(fileUploadUtil.getParameterValues("inter"));
        fileUploadUtil.saveAll(request.getServletContext().getRealPath("/")+"upload");

    %>
</body>
</html>
